const app = getApp();
Page({
    data: {
      post_value: {},
      tabIdx: 0,
      menuIdx: 0,
    },
    onLoad: function(t) {
      var that =this
      var a = that.data.tabInfo
      app.ihttpGet('https://www.58zltc.com/api.php/Commission/getMyTeamWithdraw/openid/' + app.globalData.openid, function (res) {
        wx.hideLoading()
        that.setData({
          info: res.data
        })
      })
    },
    backto: function (e) {
      wx.navigateBack({})
    },
    changeTab: function (e) {
      this.setData({
        tabIdx: e.currentTarget.dataset.num
      })
    },
    changeMenu: function (e) {
      this.setData({
        menuIdx: e.currentTarget.dataset.num
      })
    },
    inputChange: function (e) {
      let that = this
      var name = e.currentTarget.dataset.name;
      var a = that.data.post_value
      if (name == 'wxname') {
        a.wxname = e.detail.value
        that.setData({
          post_value: a
        })
      }
      if (name == 'realname') {
        a.realname = e.detail.value
        that.setData({
          post_value: a
        })
      }
    },
    but: function () {
      let that = this;
      var v = that.data.post_value
      v.openid = app.globalData.openid
      v.apply_money = that.data.info.wite_money
      v.ratio_money = that.data.info.ratio_money
      v.ratio = that.data.info.ratio
      v.really_money = that.data.info.wite_money - that.data.info.ratio_money
      app.ihttpPost('https://www.58zltc.com/api.php/Commission/takeBonus', v,  function (res) {
        wx.hideLoading()
        var data = res.data
        var icon
        data.error == 0 ? icon = 'success' : icon = 'none'
        wx.showToast({
          title: data.msg,
          icon: icon,
          duration: 1500
        })
      })
    }
});